#define _CRT_SECURE_NO_WARNINGS
#include "two_op.h"
#include <string.h>
#include "util.h"

TwoOp::TwoOp()
{
    int n1, n2, n3;
    char o1, o2;
    o1 = randBetween(0, 1) ? '+' : '-';
    o2 = randBetween(0, 1) ? '+' : '-';

    int t;
    if (o1 == '+') {
        n1 = randBetween(0, BOUND);
        n2 = randBetween(0, BOUND);
        t = n1 + n2;
    } else {
        n1 = randBetween(0, BOUND);
        n2 = randBetween(0, n1);
        t = n1 - n2;
    }

    if (o2 == '+') {
        n3 = randBetween(0, BOUND);
        stdAns = t + n3;
    } else {
        n3 = randBetween(0, t);
        stdAns = t - n3;
    }
    sprintf(expr, "%d %c %d %c %d", n1, o1, n2, o2, n3);
}